<template>
  <!-- 动态表单的内部实现  -->
  <section>
    <el-form :disabled="disabled" :inline="inline">
      <template v-for="item in fieldMap">
        <el-form-item :prop="item.name" :label="item.label">
          <!-- 文本框 -->
          <template v-if="item.type === 'text'">
            <el-input v-model="formData[item.name]" type="text" :placeholder="item.placeholder" />
          </template>
          <!-- 下拉选择框 -->
          <template v-else-if="item.type === 'select'">
            <el-select v-model="formData[item.name]" :placeholder="item.placeholder">
              <template v-for="optionItem in item.options.list">
                <el-option :label="optionItem.label" :value="optionItem.value" />
              </template>
            </el-select>
          </template>
        </el-form-item>
      </template>
    </el-form>
  </section>
</template>

<script setup lang="ts">
  import { defineProps } from 'vue'
  defineProps({
    fieldMap: {
      type: Object,
      default: () => {
        return {}
      }
    },
    formData: {
      type: Object,
      default: () => {
        return {}
      }
    },
    disabled: {
      type: Boolean,
      default: false
    },
    inline: {
      type: Boolean,
      default: false
    }
  })
</script>

<style scoped lang="scss"></style>
